<?php

namespace Mlym\CodeGeneration\InitGeneration\Router;

use EasySwoole\HttpAnnotation\Utility\Scanner;
use FastRoute\RouteCollector;
use Mlym\CodeGeneration\ClassGeneration\ClassGeneration;

class RouterGeneration extends ClassGeneration
{
    function addClassData()
    {
        $this->phpNamespace->addUse(Scanner::class);
        $this->phpNamespace->addUse(RouteCollector::class);
        $method = $this->getPhpClass()->addMethod('initialize');
        $method->addParameter('routeCollector')->setType(RouteCollector::class);
        $method->setBody(<<<BODY
\$scanner = new Scanner();
\$scanner->mappingRouter(\$routeCollector, EASYSWOOLE_ROOT . '/App/HttpController', 'App\HttpController');
BODY
        );
    }
}